﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class user_setPassword : Wozuji.Logic.PageLogin
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Header.Title = "足迹网 用户修改密码";
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        oldmsg.Text = "";
        newpassmsg1.Text = "";
        newpassmsg.Text = "";
        savemsg.Text = "";
        
        if (oldpass.Text.Equals(""))
        {
            oldmsg.Text = "请输入原密码";
        }
        else if(password.Text.Equals("")) {
            oldmsg.Text = "";
            newpassmsg1.Text = "请输入新密码";
            
        }
        else if (password.Text.Length < 6)
        {
            newpassmsg1.Text = "密码必须多于6个字符";
        }
        else if (!password.Text.ToString().Equals(passConfirm.Text.ToString()))
        {
            newpassmsg.Text = "两次密码输入不正确";
        }
        else { 
            //老密码校验
            Wozuji.BLL.Member_t mbbll = new Wozuji.BLL.Member_t();
            Wozuji.Model.Member_t mb = new Wozuji.Model.Member_t();
            mb = mbbll.GetModel(Convert.ToInt32(Session["userid"].ToString()));
            String enpass = Wozuji.Common.Util.StringUtil.EncryptPassword(oldpass.Text, Wozuji.Common.Util.StringUtil.PasswordType.MD5.ToString());

            if (!enpass.Equals(mb.Member_Password.Trim()))
            {
                oldmsg.Text = "原密码不正确";
            }
            else
            {
               mb.Member_Password=Wozuji.Common.Util.StringUtil.EncryptPassword(password.Text, Wozuji.Common.Util.StringUtil.PasswordType.MD5.ToString());
                mbbll.Update(mb);
                savemsg.Text = "修改成功";
            }
            mb=null;
            mbbll=null;
        }
    }
}
